package com.atguigu.tingshu.account.service.impl;

import com.atguigu.tingshu.account.mapper.UserAccountMapper;
import com.atguigu.tingshu.account.service.MqOpsService;
import com.atguigu.tingshu.common.execption.GuiguException;
import com.atguigu.tingshu.model.account.UserAccount;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @BelongsProject: tingshu-backend
 * @BelongsPackage: com.atguigu.tingshu.account.service.impl
 * @Author: coilk
 * @CreateTime: 2025-03-12  09:55
 * @Description:
 * @Version: 1.0
 */
@Service
@Slf4j
public class MqOpsServiceImpl implements MqOpsService {
    @Autowired
    private UserAccountMapper userAccountMapper;
    @Override
    public void userAccountRegister(String content) {


        try {
            UserAccount userAccount = new UserAccount();
            userAccount.setUserId(Long.parseLong(content));
            int insert = userAccountMapper.insert(userAccount);
            log.info("初始化用户账户：{}", insert > 0 ? "success" : "fail");
        } catch (Exception e) {
            throw new GuiguException(201, "服务内部处理数据失败");
        }

    }
}
